﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClearingRestartingAutomaton.Base
{
    /// <summary>
    /// The structure WordForest describes the rooted forest of words obtained from 
    /// the given initial list of words by applying the given set of instructions.
    /// Only one of the two possible ways how to apply instructions is used.
    /// </summary>
    [Serializable]
    public struct WordForest
    {
        #region Constructors

        /// <summary>
        /// Constructor of this structure.
        /// </summary>
        /// <param name="initialWords">The initial list of words.</param>
        /// <param name="leftContext">The left context of the given initial list of words.</param>
        /// <param name="rightContext">The right context of the given initial list of words.</param>
        /// <param name="instructionUse">The way the instructions are used.</param>
        /// <param name="forestList">The list of all words in the forest.</param>
        /// <param name="forestSet">The set of all words in the forest.</param>
        /// <param name="forestSteps">The dictionary mapping each word in the forest to the list of InstructionStep structures which lead to this word.</param>
        public WordForest(
            List<string> initialWords,
            string leftContext,
            string rightContext,
            InstructionUse instructionUse,
            List<string> forestList,
            SortedDictionary<string, int> forestSet,
            SortedDictionary<string, List<InstructionStep>> forestSteps)
        {
            this.initialWords = initialWords;
            this.leftContext = leftContext;
            this.rightContext = rightContext;
            this.use = instructionUse;
            this.forestList = forestList;
            this.forestSet = forestSet;
            this.forestSteps = forestSteps;
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// The initial list of words.
        /// </summary>
        public List<string> InitialWords
        {
            get { return this.initialWords; }
        }

        /// <summary>
        /// The left context of the given initial list of words.
        /// </summary>
        public string LeftContext
        {
            get { return this.leftContext; }
        }

        /// <summary>
        /// The right context of the given initial list of words.
        /// </summary>
        public string RightContext
        {
            get { return this.rightContext; }
        }

        /// <summary>
        /// The way the instructions are used.
        /// </summary>
        public InstructionUse Use
        {
            get { return this.use; }
        }

        /// <summary>
        /// The list of all words in the forest.
        /// </summary>
        public List<string> ForestList
        {
            get { return this.forestList; }
        }

        /// <summary>
        /// The set of all words in the forest.
        /// </summary>
        public SortedDictionary<string, int> ForestSet
        {
            get { return this.forestSet; }
        }

        /// <summary>
        /// The dictionary mapping each word in the forest to the list of InstructionStep structures which lead to this word.
        /// </summary>
        public SortedDictionary<string, List<InstructionStep>> ForestSteps
        {
            get { return this.forestSteps; }
        }

        #endregion

        #region Private Data Members

        private List<string> initialWords;
        private string leftContext;
        private string rightContext;
        private InstructionUse use;
        private List<string> forestList;
        private SortedDictionary<string, int> forestSet;
        private SortedDictionary<string, List<InstructionStep>> forestSteps;

        #endregion
    }
}
